﻿CREATE PROCEDURE [dbo].[EditorFindKey]
	@UserName nVarChar(50) = NULL,
	@EmailAddress nVarChar(254) = NULL
AS

SET NOCOUNT ON

	IF (@UserName IS NULL AND @EmailAddress IS NULL) OR (@UserName IS NOT NULL AND @EmailAddress IS NOT NULL) BEGIN
		RAISERROR ('One of @UserName, @EmailAddress must be non-null.', 15, 0)
		RETURN
	END

IF (@UserName IS NOT NULL)
	SELECT EditorKey FROM Editor WHERE UserName = @UserName
ELSE IF (@EmailAddress IS NOT NULL)
	SELECT EditorKey FROM Editor WHERE EmailAddress = @EmailAddress


RETURN 0
